class Commodity_specification {
    /**
     * 新增商品规格
     * @param commodityId 商品id
     * @param specificationsPrice 商品规格价格
     * @param specificationsTypeId 规格类别Id
     * @param specificationsInput 规格名称
     * @returns {Promise<json>}
     */
    insertCommoditySpecification(commodityId,specificationsPrice,specificationsTypeId,specificationsInput){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/background/insert/commodity/specification",
                method: "POST",
                data: {
                    commodityId:commodityId,
                    specificationsPrice:specificationsPrice,
                    specificationsTypeId:specificationsTypeId,
                    specificationsInput:specificationsInput
                },
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        })
    }

    /**
     * 根据 specification_type_id 和 commodity_id 删除 commodity_specification
     *
     * @param specificationTypeId 规格类型ID
     * @param commodityId         商品ID
     * @return {Promise<boolean>} true删除成功 false删除失败
     */
    deleteCommoditySpecification(specificationTypeId,commodityId){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/background/delete/commodity/specification",
                method: "GET",
                data: {
                    commodityId:commodityId,
                    specificationTypeId:specificationTypeId,
                },
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        })
    }
    /**
     * 根据 specification_id 和 commodity_id 删除 commodity_specification
     * @param specificationId 规格ID
     * @param commodityId     商品ID
     * @return 删除成功返回 true，失败返回 false
     */
    deleteCommoditySpecificationByIds(specificationId,commodityId){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/background/delete/commodity/specification/by/id",
                method: "GET",
                data: {
                    commodityId:commodityId,
                    specificationId:specificationId,
                },
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        })
    }
}